package com.schooleducation.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.schooleducation.entity.Lesson;
import com.schooleducation.entity.LessonContent;
import com.schooleducation.service.ServiceFactory;

/**
 * 前台首页界面控制
 * 
 * @author weijing
 *
 */
@Controller
@RequestMapping("/index")
public class IndexController {

	@Resource(name = "serviceFac")
	private ServiceFactory serviceFac;
	
	/**
	 * 获取页面
	 * @param session
	 * @param model
	 * @return
	 */
	@RequestMapping(method = RequestMethod.GET)
	public String indexPage(HttpSession session, Model model) {
		List<Lesson> nls = this.serviceFac.getLessonService().getNewLessonList(0, 8);
		List<Lesson> hls = this.serviceFac.getLessonService().gethotLessonList(0, 8);
		List<LessonContent> nlcs = this.serviceFac.getLessonService().getNewLessonContentList(0, 10);
		
		model.addAttribute("user", session.getAttribute("user"));
		model.addAttribute("newLesson", nls);
		model.addAttribute("hotLesson", hls);
		model.addAttribute("newContent", nlcs);
		
		return "../index";
	}
}
